package com.findme.gui;

import com.findme.controller.ControllerUsuario;
import com.findme.findme.R;
import com.findme.model.Usuario;
import com.findme.uteis.alertaDialog;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

public class TelaNovaConta extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_tela_nova_conta);
		
		ImageView  btnConfirma  = (ImageView) findViewById(R.id.imgVwConfirmaNovaConta);
			
		btnConfirma.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				
				alertaDialog alerta = new alertaDialog();//erro cadastro grupo
				
				//captura campos,carrega a classe e executa o controlador
				EditText  edtFone  = (EditText) findViewById(R.id.edtFoneNovaConta);
				EditText  edtSenha  = (EditText) findViewById(R.id.edtSenhaNovaConta);		
				EditText  edtNome  = (EditText) findViewById(R.id.edtNomeNovaConta);
				EditText  edtEmail  = (EditText) findViewById(R.id.edtEmailNovaConta);	
				
		     	Usuario user = new Usuario();
		     	user.setEmail(edtEmail.getText().toString().trim());
		     	user.setSenha(edtSenha.getText().toString().trim());
		     	user.setFone(edtFone.getText().toString().trim());
		     	user.setNome(edtNome.getText().toString().trim());	
		     	
			    ControllerUsuario ct = new ControllerUsuario(user);				
				
			    if(ct.incluir(TelaNovaConta.this)){//se cadastrou
			       // finish();					
			    	edtEmail.setText("");
			    	edtSenha.setText("");
			    	edtFone.setText("");
			    	edtNome.setText("");
				}
							
				

			}
			
		});			
		
		
		
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.tela_nova_conta, menu);
		return true;
	}

}
